<template>
  <div class="head-container">
    <!-- 搜索 -->
    <el-input v-model="query.typename" clearable placeholder="类型" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
    <el-input v-model="query.sparepartname" clearable placeholder="名称" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
    <el-input v-model="query.spareparttmodel" clearable placeholder="型号" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
    <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
    <!-- 新增 -->
    <div style="display: inline-block;margin: 0px 2px;">
      <el-button
        v-permission="['ADMIN','TSPAREPART_ALL','TSPAREPART_CREATE']"
        class="filter-item"
        size="mini"
        type="primary"
        icon="el-icon-plus"
        @click="newSparepart">新增</el-button>
      <eForm ref="form" :is-add="true" :eqpt-id="eqptId"/>
    </div>
  </div>
</template>

<script>
import eForm from './form'
import { log } from 'util'
export default {
  components: { eForm },
  props: {
    query: {
      type: Object,
      required: true
    },
    eqptId: {
       type: Number,
       default: -1
    }
  },
  data() {
    return {
      queryTypeOptions: [
        { key: 'typename', display_name: '类型' },
        { key: 'sparepartname', display_name: '名称' },
        { key: 'spareparttmodel', display_name: '型号' }
      ]
    }
  },
  methods: {
    toQuery() {
      this.$parent.page = 0
      this.$parent.init()
    },
    newSparepart() {
      this.$refs.form.dialog = true
      this.$refs.form.getSpareparttmodel()
      this.$refs.form.getSparepartBrand()
    },
  }
}
</script>
